﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_Flow_GetNotBangdingStaff]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_Flow_GetNotBangdingStaff];
GO
CREATE PROCEDURE [dbo].[sproc_Flow_GetNotBangdingStaff]
    @FlowID int,
    @StepID int
AS
BEGIN
SET NOCOUNT ON;

SELECT
		staff_id,
		realname as staff_name
    FROM
		dbo.uds_staff 
    WHERE staff_id not in
		(
			SELECT b.staff_id     
			FROM
				dbo.uds_flow_member_bind a ,
				dbo.uds_staff b 
			WHERE
				a.obj_id = b.staff_id 
				and a.flow_id = @flowid
				and a.step_id = @stepid
				and a.obj_type = 4 /* staff */
        )
     and dimission = 0;

END
GO